const maxProfit2 = function(prices){
  let profit = 0;
  for(let i = 1; i < prices.length; i++){
    if(prices[i]-prices[i-1] > 0){
      profit+=prices[i]-prices[i-1];
    }
  }
  return profit;
}